

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>The util module &mdash; pyamp v1.2 documentation</title>
    <link rel="stylesheet" href="_static/default.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '',
        VERSION:     '1.2',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="_static/jquery.js"></script>
    <script type="text/javascript" src="_static/underscore.js"></script>
    <script type="text/javascript" src="_static/doctools.js"></script>
    <link rel="top" title="pyamp v1.2 documentation" href="index.html" /> 
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li><a href="index.html">pyamp v1.2 documentation</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="module-pyamp.util">
<span id="the-util-module"></span><h1>The util module<a class="headerlink" href="#module-pyamp.util" title="Permalink to this headline">¶</a></h1>
<p>The util module contains utility methods for various types
of actions such as manipulating strings, or debugging systems.</p>
<div class="section" id="module-pyamp.util.debugging">
<span id="the-debugging-module"></span><h2>The debugging module<a class="headerlink" href="#module-pyamp.util.debugging" title="Permalink to this headline">¶</a></h2>
<p>The debugging module contains utility methods which are useful when
debugging systems.</p>
<dl class="function">
<dt id="pyamp.util.debugging.getStackTrace">
<tt class="descclassname">pyamp.util.debugging.</tt><tt class="descname">getStackTrace</tt><big>(</big><big>)</big><a class="reference internal" href="_modules/pyamp/util/debugging.html#getStackTrace"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyamp.util.debugging.getStackTrace" title="Permalink to this definition">¶</a></dt>
<dd><p>Get the current stack trace as a string.</p>
</dd></dl>

<dl class="function">
<dt id="pyamp.util.debugging.getClassName">
<tt class="descclassname">pyamp.util.debugging.</tt><tt class="descname">getClassName</tt><big>(</big><em>obj</em><big>)</big><a class="reference internal" href="_modules/pyamp/util/debugging.html#getClassName"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyamp.util.debugging.getClassName" title="Permalink to this definition">¶</a></dt>
<dd><p>Get the class name for the given object.</p>
<ul class="simple">
<li>obj &#8211; The object</li>
</ul>
</dd></dl>

</div>
<div class="section" id="module-pyamp.util.dictionary">
<span id="the-dictionary-module"></span><h2>The dictionary module<a class="headerlink" href="#module-pyamp.util.dictionary" title="Permalink to this headline">¶</a></h2>
<p>The dictionary module Contains utility methods for manipulating and dealing
with dictionary objects.</p>
<dl class="function">
<dt id="pyamp.util.dictionary.addNotNone">
<tt class="descclassname">pyamp.util.dictionary.</tt><tt class="descname">addNotNone</tt><big>(</big><em>dictionary</em>, <em>key</em>, <em>value</em><big>)</big><a class="reference internal" href="_modules/pyamp/util/dictionary.html#addNotNone"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyamp.util.dictionary.addNotNone" title="Permalink to this definition">¶</a></dt>
<dd><p>Add the given value for the given key to the dictionary, only if the
value is not None.</p>
<ul class="simple">
<li>dictionary &#8211; The dictionary to add the key to</li>
<li>key &#8211; The key</li>
<li>value &#8211; The value for the key</li>
</ul>
</dd></dl>

<dl class="function">
<dt id="pyamp.util.dictionary.getItems">
<tt class="descclassname">pyamp.util.dictionary.</tt><tt class="descname">getItems</tt><big>(</big><em>dictionary</em>, <em>items</em>, <em>default=None</em><big>)</big><a class="reference internal" href="_modules/pyamp/util/dictionary.html#getItems"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyamp.util.dictionary.getItems" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the given items in the dictionary, each item is taken
from the dictionary contained within the previous item, and if
one of the items in the chain does not exist this function
returns the default value.</p>
<p>Example:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">pyamp.util.dictionary</span> <span class="kn">import</span> <span class="n">getItems</span>

<span class="n">d</span> <span class="o">=</span> <span class="p">{</span><span class="s">&quot;first&quot;</span><span class="p">:</span> <span class="p">{</span><span class="s">&quot;second&quot;</span><span class="p">:</span> <span class="p">{</span><span class="s">&quot;third&quot;</span><span class="p">:</span> <span class="mi">500</span><span class="p">}}}</span>

<span class="c"># Prints: 500</span>
<span class="k">print</span> <span class="n">getItems</span><span class="p">(</span><span class="n">d</span><span class="p">,</span> <span class="p">[</span><span class="s">&quot;first&quot;</span><span class="p">,</span> <span class="s">&quot;second&quot;</span><span class="p">,</span> <span class="s">&quot;third&quot;</span><span class="p">])</span>

<span class="c"># Prints: 200</span>
<span class="k">print</span> <span class="n">getItems</span><span class="p">(</span><span class="n">d</span><span class="p">,</span> <span class="p">[</span><span class="s">&quot;first&quot;</span><span class="p">,</span> <span class="s">&quot;non-existent&quot;</span><span class="p">],</span> <span class="mi">200</span><span class="p">)</span>
</pre></div>
</div>
<ul class="simple">
<li>dictionary &#8211; The dictionary</li>
<li>items &#8211; The list of items</li>
<li>default &#8211; The default value</li>
</ul>
</dd></dl>

</div>
<div class="section" id="module-pyamp.util.sockets">
<span id="the-sockets-module"></span><h2>The sockets module<a class="headerlink" href="#module-pyamp.util.sockets" title="Permalink to this headline">¶</a></h2>
<p>Contains utility methods for modifying socket attributes.</p>
<dl class="function">
<dt id="pyamp.util.sockets.setReusable">
<tt class="descclassname">pyamp.util.sockets.</tt><tt class="descname">setReusable</tt><big>(</big><em>sockFd</em><big>)</big><a class="reference internal" href="_modules/pyamp/util/sockets.html#setReusable"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyamp.util.sockets.setReusable" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the given socket to be reusable.</p>
<ul class="simple">
<li>sockFd &#8211; The socket file descriptor</li>
</ul>
</dd></dl>

</div>
<div class="section" id="module-pyamp.util.strings">
<span id="the-strings-module"></span><h2>The strings module<a class="headerlink" href="#module-pyamp.util.strings" title="Permalink to this headline">¶</a></h2>
<p>Contains utility methods pertaining to strings.</p>
<dl class="function">
<dt id="pyamp.util.strings.levenshtein">
<tt class="descclassname">pyamp.util.strings.</tt><tt class="descname">levenshtein</tt><big>(</big><em>str1</em>, <em>str2</em>, <em>case=True</em><big>)</big><a class="reference internal" href="_modules/pyamp/util/strings.html#levenshtein"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyamp.util.strings.levenshtein" title="Permalink to this definition">¶</a></dt>
<dd><p>Calculate the Levenshtein distance between two strings.</p>
<ul class="simple">
<li>str1 &#8211; The first string</li>
<li>str2 &#8211; The second string</li>
<li>case &#8211; True for case sensitivity, False otherwise</li>
</ul>
</dd></dl>

</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
  <h3><a href="index.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">The util module</a><ul>
<li><a class="reference internal" href="#module-pyamp.util.debugging">The debugging module</a></li>
<li><a class="reference internal" href="#module-pyamp.util.dictionary">The dictionary module</a></li>
<li><a class="reference internal" href="#module-pyamp.util.sockets">The sockets module</a></li>
<li><a class="reference internal" href="#module-pyamp.util.strings">The strings module</a></li>
</ul>
</li>
</ul>

  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="_sources/util.txt"
           rel="nofollow">Show Source</a></li>
  </ul>
<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="search.html" method="get">
      <input type="text" name="q" size="18" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li><a href="index.html">pyamp v1.2 documentation</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright 2012, Brett Ponsler.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.1.
    </div>
  </body>
</html>